import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import * as process from "node:process"
const LIB_ENTRY = process.env.LIB_ENTRY as string
const LIB_NAME = process.env.LIB_NAME as string 
console.debug(LIB_ENTRY,LIB_NAME)
// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  build: {
    outDir: `dist/${LIB_NAME}`,
    lib: {
      entry: LIB_ENTRY,
      name: LIB_NAME,
      // 将添加适当的扩展名后缀
      fileName: LIB_NAME,
    },
    rollupOptions: {
      // 确保外部化处理那些
      // 你不想打包进库的依赖
      external: ['vue'],
      output: {
        // 在 UMD 构建模式下为这些外部化的依赖
        // 提供一个全局变量
        globals: {
          vue: 'Vue',
        },

      },
    },
  },
})
